package com.example.myword.dao;


import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface WordDao {
    @Insert
    void insert(Word word);

    @Delete
    void delete(Word word);

    @Update
    void update(Word word);

    @Query("SELECT * FROM words WHERE userId = :userId ORDER BY wrongCount DESC")
    List<Word> getAllWords(String userId);

    @Query("SELECT * FROM words WHERE userId = :userId AND word = :word LIMIT 1")
    Word getWord(String userId,String word);

    @Query("Delete FROM words WHERE userId = :userId AND word = :word")
    void deleteWordsForUser(String userId,String word);
}
